package com.supplychainapi.service.impl;

import com.supplychainapi.dao.prod.ScmTbfinderlistMapper;
import com.supplychainapi.model.ScmTbfinderlist;
import com.supplychainapi.service.ITbfinderlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ITbfinderlistServiceImpl implements ITbfinderlistService
{
    @Autowired
    ScmTbfinderlistMapper tbfinderlistMapper;

    @Override
    public boolean save(ScmTbfinderlist model) {
        ScmTbfinderlist result=select(model);
        int i=0;
        boolean bool=true;
        model.setFsUpdateTime(new Date());
        if(null==result){
             i=tbfinderlistMapper.insertSelective(model);
        }else{
             bool=update(model);
        }
        if(i<=0 || !bool){
            return false;
//            throw ExceptionMessage.operation_failed.getServiceException();
        }
        return true;

    }

    @Override
    public boolean update(ScmTbfinderlist model) {
        int i=tbfinderlistMapper.updateByPrimaryKeySelective(model);
        if(i<=0){
            return false;
//            throw ExceptionMessage.operation_failed.getServiceException();
        }
        return true;
    }

    @Override
    public boolean delete(ScmTbfinderlist model) {
        int i=tbfinderlistMapper.deleteByPrimaryKey(model);
        if(i<=0){
            return false;
//            throw ExceptionMessage.operation_failed.getServiceException();
        }
        return true;
    }

    @Override
    public ScmTbfinderlist select(ScmTbfinderlist model) {
        ScmTbfinderlist result=tbfinderlistMapper.selectByPrimaryKey(model);
        return result;
    }
}
